package com.chushouya.manager.dao.repository;



import com.general.framework.core.lang.Strings;
import com.general.framework.data.mybatis.BaseRepository;
import com.chushouya.manager.dao.entity.AppConfigListEntity;
import com.chushouya.manager.dao.mapper.AppConfigListEntityMapper;
import com.chushouya.manager.dto.admin.appconfiglist.AppConfigQuery;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

@Repository
public class AppConfigListRepository extends BaseRepository<AppConfigListEntityMapper, AppConfigListEntity, Long> {

    public List<AppConfigListEntity> selectList(AppConfigQuery query) {
        return selectByExample(buildExample(query));
    }

    public AppConfigListEntity selectOne(AppConfigQuery query) {
        return selectFirstOneByExample(buildExample(query));
    }


    private Example buildExample(AppConfigQuery query) {
        Example example = buildExample();
        Example.Criteria c = example.createCriteria();
        if (Strings.isNotBlank(query.getAppId())) {
            c.andEqualTo("appId", query.getAppId());
        }
        return example;
    }

}
